﻿using System.Reflection;

namespace Borg
{
    public class ExtensionEventArgs : SystemEventArgs
    {
        internal readonly ExtensionInfo extensionInfo;
        internal readonly ExtensionTypeInfo extensionTypeInfo;

        public PluginInfo PluginInfo
        {
            get { return extensionTypeInfo.pluginInfo; }
        }

        public ExtensionTypeInfo ExtensionTypeInfo
        {
            get { return extensionTypeInfo; }
        }

        public ExtensionInfo ExtensionInfo
        {
            get { return extensionInfo; }
        }

        public object Extension
        {
            get { return extensionInfo.Object; }
        }

        public ExtensionEventArgs(ExtensionInfo extensionInfo, Assembly initiator)
            : base(initiator)
        {
            this.extensionInfo = extensionInfo;
            extensionTypeInfo = extensionInfo.extensionTypeInfo;
        }

        public ExtensionEventArgs(ExtensionTypeInfo extensionTypeInfo, Assembly initiator)
            : base(initiator)
        {
            this.extensionTypeInfo = extensionTypeInfo;
        }

        public void LogEvent(LogEventArgs args)
        {
            Runtime.OnLogEvent(extensionInfo, args);
        }
    }

    public delegate void ExtensionEventHandler(object sender, ExtensionEventArgs args);
}

